using System;
using System.Collections.Generic;
using System.Text;

namespace Multiplicity.Reflection {
    [Serializable]
    public class MetadataException : Exception {

        public MetadataException() { }
        public MetadataException(string message) : base(message) { }
        public MetadataException(string message, Exception inner) : base(message, inner) { }
        protected MetadataException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context)
            : base(info, context) { }

        internal static void ThrowInvalidHeader() {
            throw new Multiplicity.Reflection.MetadataException("Invalid metadata header");
        }
        internal static void ThrowInvalidModuleName() {
            throw new Multiplicity.Reflection.MetadataException("Invalid module name");
        }
        internal static void ThrowUnknownStorageHeap(string heapName) {
            throw new Multiplicity.Reflection.MetadataException(string.Format("Unknown storage heap '{0}'", heapName));
        }
        internal static void ThrowStorageHeapNotFound(string heapName) {
            throw new Multiplicity.Reflection.MetadataException(string.Format("Storage heap '{0}' not found", heapName));
        }
        internal static void ThrowUnknownVersion(Version ver) {
            throw new Multiplicity.Reflection.MetadataException(string.Format("Unknown metadata version {0}", ver));
        }

        internal static void ThrowSignatureBlobException() {
            throw new Multiplicity.Reflection.MetadataException("Invalid signature blob");
        }

        internal static void ThrowUnexpectedSignatureElement(SignatureElement element) {
            throw new Multiplicity.Reflection.MetadataException(string.Format("Signature element {0} not expected", element));
        }

        internal static void ThrowInvalidToken(uint token) {
            throw new Multiplicity.Reflection.MetadataException(string.Format("Invalid token 0x{0:x}", token));
        }
    }
}